<div class="da-list-wrap">
  <div class="da-content-banner">
    <d-breadcrumb>
      <d-breadcrumb-item><a routerLink="/">{{ 'basicdata.breadcrumb.home' | translate }}</a></d-breadcrumb-item>
      <d-breadcrumb-item>{{ 'basicdata.breadcrumb.storehouse' | translate }}</d-breadcrumb-item>
    </d-breadcrumb>
  </div>
  <div class="da-content-wrapper">
    <div class="departments">
      <div class="card">
        <div class="card-title">
          <span>仓库类别</span>
        </div>
        <div class="fitter mt-3">
          <input dTextInput placeholder="请输入" name="searchWarehouseCategoryValue"
            (input)="searchWarehouseCategory($event)" />
        </div>
        <div class="card-body">
          <d-tree #basicTree [tree]="displayTreeData" [treeNodeIdKey]="'warehouseCategoryNum'"
            [treeNodeTitleKey]="'warehouseCategoryName'" [treeNodeChildrenKey]="'subWarehouseCategories'"
            (afterTreeInit)="afterTreeInit($event)" (nodeSelected)="nodeSelected($event)">
          </d-tree>
        </div>
        <div class="card-footer d-flex align-items-bottom justify-content-center">
          <div class="dDropDown" dDropDown appendToBody [trigger]="'click'" [appendToBodyDirections]="['centerUp']">
            <d-button-group>
              <d-button bsStyle="common" class="" bsSize="sm" (btnClick)="CreatDepartment()">
                新增
              </d-button>
              <d-button class="more" icon="icon-select-arrow" bsSize="sm" dDropDownToggle bsStyle="common"></d-button>
            </d-button-group>
            <ul dDropDownMenu class="devui-dropdown-menu devui-scrollbar" role="menu">
              <li role="menuitem">
                <a dDropDownMenuItem (click)="EditDepartment()"
                  [ngClass]="{'disabled':!this.warehouseCategoryId}">编辑</a>
              </li>
              <li role="menuitem">
                <a dDropDownMenuItem (click)="DeleteDepartment()"
                  [ngClass]="{'disabled':!this.warehouseCategoryId}">删除</a>
              </li>
            </ul>
          </div>
          <div class="dDropDown" dDropDown appendToBody [trigger]="'click'" [appendToBodyDirections]="['centerUp']">
            <input type="file" #fileInput2 style="display: none" (change)="ImportCategory($event)">
            <d-button-group>
              <d-button bsStyle="common" class="" bsSize="sm" (btnClick)="onButtonClick2()">
                导入
              </d-button>
              <d-button class="more" icon="icon-select-arrow" bsSize="sm" dDropDownToggle bsStyle="common"></d-button>
            </d-button-group>
            <ul dDropDownMenu class="devui-dropdown-menu devui-scrollbar" role="menu">
              <li role="menuitem" (click)="DownloadCategoryModel()">
                <a dDropDownMenuItem>下载模板</a>
              </li>
            </ul>
          </div>
        </div>
      </div>
    </div>
    <div class="employs-box">
      <div class="card">
        <div class="card-header">
          <div>
            <div class="d-input">
              <input dTextInput style="width: 150px;" [error]="false" placeholder="仓库名称" [(ngModel)]="SearchTerm"
                name="SearchTerm">
              <d-select  [options]="selectoptions" [(ngModel)]="selectvalue" (valueChange)="selctChange()"
                style="width: 150px; height: 33px; margin-left: 5px;"></d-select>
            </div>
            <d-button id="primaryBtn" (click)="search()"><i
                class="icon icon-filter-o me-2"></i>查询</d-button>
            <d-button bsStyle="common" (btnClick)=" reset()"> <i class="icon icon-refresh me-2"></i>重置</d-button>
          </div>
        </div>
        <div class="btn-group">
          <d-button bsStyle="primary" (btnClick)="creatStorehouse()"> <i class="icon icon-add me-2"></i>新增</d-button>
          <d-button bsStyle="success" (btnClick)="enabled()"><i class="icon icon-right me-2"></i>启用</d-button>
          <d-button bsStyle="warning" (btnClick)="disabled()"><i class="icon icon-error me-2"></i>禁用</d-button>
          <d-button bsStyle="danger" (btnClick)="deltes()"><i class="icon icon-delete me-2"></i>删除</d-button>
          <div class="dDropDown" dDropDown [trigger]="'hover'">
            <input type="file" #fileInput1 style="display: none" (change)="importFormExcel($event)">
            <d-button bsStyle="common" class="devui-dropdown-origin" (btnClick)="onButtonClick()">
              导入
              <span class="icon-select-arrow"></span>
            </d-button>
            <d-button bsStyle="common" (btnClick)="DownloadWarehouse()"> <i
                class="icon icon-merge me-2"></i>导出</d-button>
            <ul dDropDownMenu class="devui-dropdown-menu devui-scrollbar" role="menu">
              <li role="menuitem">
                <a dDropDownMenuItem (click)="DownloadModel()">下载模板</a>
              </li>
            </ul>
          </div>
        </div>
        <div class="list-content">
          <d-data-table [lazy]="true" [dataSource]="displayTableData" [scrollable]="true" [fixHeader]="true"
            [resizeable]="true" [tableWidthConfig]="tableWidthConfig" (checkAllChange)="getCheckedRows()"
            (rowCheckChange)="getCheckedRows()" [tableOverflowType]="'auto'" [scrollable]="true" [resizeable]="true"
            [colDraggable]="true">
            <thead dTableHead [checkable]="true">
              <tr dTableRow>
                <th dHeadCell [fixedLeft]="'80px'">
                  操作
                </th>
                <th dHeadCell *ngFor="let colOption of dataTableOptions.columns">{{ colOption.header }}</th>
              </tr>
            </thead>
            <tbody dTableBody>
              <ng-template let-rowItem="rowItem" let-rowIndex="rowIndex" let-nestedIndex="nestedIndex">
                <tr dTableRow>
                  <td dTableCell [fixedLeft]="'0px'">
                    <d-checkbox [disabled]="false" [showAnimation]="true" [showGlowStyle]="false"
                      [ngModelOptions]="{ standalone: true }" [ngModel]="rowItem.$checked" dTooltip
                      (ngModelChange)="onRowCheckChange($event, rowIndex, nestedIndex, rowItem)"></d-checkbox>
                  </td>
                  <td dTableCell [fixedLeft]="'80px'" [rowItem]="rowItem">
                    <span class="me-2" (click)="edit(rowItem.warehouseId)"><a class="devui-link">编辑</a></span>
                    <span class="me-2" (click)="positionData(rowItem)"><a class="devui-link">仓位信息</a></span>
                    <span><a class="devui-link-danger" (click)="delete(rowItem.warehouseId)">删除</a></span>
                  </td>
                  <td dTableCell [rowItem]="rowItem">
                    <span dTooltip [content]="rowItem?.warehouseNum">{{rowItem?.warehouseNum}}</span>
                  </td>
                  <td dTableCell [rowItem]="rowItem">
                    <span dTooltip [content]="rowItem?.warehouseName">{{rowItem?.warehouseName}}</span>
                  </td>
                  <td dTableCell [rowItem]="rowItem">
                    <span dTooltip [content]="rowItem?.isNegative | isEmpowerment">
                      <d-tag [tag]=" rowItem?.isNegative | isEmpowerment"
                        [labelStyle]="rowItem?.isNegative"></d-tag></span>
                  </td>
                  <td dTableCell [rowItem]="rowItem" [field]="'showType'">
                    <span>
                      <div dImagePreview>
                        <d-badge *ngIf="rowItem.qrCode" [count]="getImagesArray2(rowItem.qrCode).length" status="success">
                          <ng-container *ngFor="let imageUrl of getImagesArray2(rowItem.qrCode); let i = index">
                            <img *ngIf="getImagesArray2(rowItem.qrCode).length > 0" [src]="imageUrl" alt="图片" height="22px" [ngStyle]="{'display': i === 0 ? 'block' : 'none'}" />
                          </ng-container>
                        </d-badge>
                      </div>
                    </span>
                  </td>
                  <td dTableCell [rowItem]="rowItem">
                    <span dTooltip [content]="rowItem?.isEnabled | status"><d-tag [tag]=" rowItem?.isEnabled | status" [labelStyle]="rowItem?.isEnabled"></d-tag></span>
                  </td>
                </tr>
              </ng-template>
            </tbody>
          </d-data-table>
        </div>
        <div class="page-footer">
          <div>
            <p>已选 <span class="underline">{{deleteIDs.length}}</span> 条
              <a (click)="cleared()">清空</a>
            </p>
          </div>
          <d-pagination [size]="'sm'" [canViewTotal]="true" [canChangePageSize]="true" [canJumpPage]="true"
            [maxItems]="5" [total]="this.pager.total" [pageSizeOptions]="this.pageSizeOptions"
            [(pageSize)]="pager.pageSize" [(pageIndex)]="pager.pageIndex" (pageIndexChange)="pageIndexChange($event)"
            (pageSizeChange)="pageSizeChange($event)">
          </d-pagination>
        </div>


      </div>
    </div>
  </div>
</div>

<d-toast [value]="msgs" [life]="2000" [styleClass]="'custom-class'" [style]="{ left: '50%',top:'10px' }"></d-toast>
